package com.sgzn.sgpay.web.controller;

import com.sgzn.sgpay.model.request.*;
import com.sgzn.sgpay.model.request.util.PageQueryParam;
import com.sgzn.sgpay.model.response.SgsResultResponse;
import com.sgzn.sgpay.model.response.result.DevicePageListResult;
import com.sgzn.sgpay.model.response.vo.DeviceInfoVo;
import com.sgzn.sgpay.persistence.domain.TDevice;
import com.sgzn.sgpay.service.SgsDeviceService;
import com.sgzn.sgpay.web.handle.AssembleCommonHandle;
import com.sgzn.sgpay.web.request.DeviceAddPresentRequest;
import com.sgzn.sgpay.web.request.Impl.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * 用户版设备管理控制器
 * @author zhongzhongyong
 */
@Slf4j
@Controller
@RequestMapping("/user/device")
public class UserDeviceController {
    @Resource
    private SgsDeviceService sgsDeviceService;
    @Resource
    private AssembleCommonHandle assembleCommonHandle;

    /**
     * 查询设备单价的信息
     * @param request
     * @return
     */
    @RequestMapping("queryPrice")
    @ResponseBody
    public SgsResultResponse<TDevice> queryPrice(DeviceQueryByIdRequest request) {
        return this.sgsDeviceService.queryDevicePrice(assembleQueryRequest(request));
    }

    /**
     * 组装设备单价查询请求
     * @param deviceRequest
     * @return
     */
    private SgsDeviceQueryRequest assembleQueryRequest(DeviceQueryByIdRequest deviceRequest) {
        SgsDeviceQueryRequest sgsDeviceQueryRequest = new SgsDeviceQueryRequest();
        this.assembleCommonHandle.assemble(deviceRequest, sgsDeviceQueryRequest);
        sgsDeviceQueryRequest.setDeviceId(deviceRequest.getDeviceId());
        return sgsDeviceQueryRequest;
    }

}

